WT_DECLARE_WT_MEMBER(1,JavaScriptConstructor,"WSuggestionPopup",function(s,g,y,G,q,t,z,u){function c(a){return $(a).hasClass("Wt-suggest-onedit")||$(a).hasClass("Wt-suggest-dropdown")}function e(){return g.style.display!="none"}function i(a){g.style.display="block";d.positionAtWidget(g.id,a.id,d.Vertical)}function l(a){a=d.target(a||window.event);if(!d.hasTag(a,"UL")){for(;a&&!d.hasTag(a,"LI");)a=a.parentNode;a&&p(a)}}function p(a){var b=a.firstChild.firstChild,h=d.getElement(f),k=b.innerHTML;b=b.getAttribute("sug");
h.focus();y(h,k,b);s.emit(g,"select",a.id,h.id);m();f=null}function m(){g.style.display="none";if(f!=null&&A!=null){d.getElement(f).onkeydown=A;A=null}}function B(a,b){for(a=b?a.nextSibling:a.previousSibling;a;a=b?a.nextSibling:a.previousSibling)if(d.hasTag(a,"LI"))if(a.style.display!="none")return a;return null}function J(a){var b=a.parentNode;if(a.offsetTop+a.offsetHeight>b.scrollTop+b.clientHeight)b.scrollTop=a.offsetTop+a.offsetHeight-b.clientHeight;else if(a.offsetTop<b.scrollTop)b.scrollTop=
a.offsetTop}$(".Wt-domRoot").add(g);jQuery.data(g,"obj",this);var r=this,d=s.WT,o=null,f=null,K=false,C=null,M=null,N=t,D=null,E=null,v=false;this.defaultValue=z;var A=null;this.showPopup=function(a){g.style.display="block";E=o=null;A=a.onkeydown;a.onkeydown=function(b){r.editKeyDown(this,b||window.event)}};this.editMouseMove=function(a,b){if(c(a))a.style.cursor=d.widgetCoordinates(a,b).x>a.offsetWidth-16?"default":""};this.showAt=function(a,b){m();f=a.id;v=true;r.refilter(b)};this.editClick=function(a,
b){if(c(a))if(d.widgetCoordinates(a,b).x>a.offsetWidth-16)if(f!=a.id||!e())r.showAt(a,"");else{m();f=null}};this.editKeyDown=function(a,b){if(!c(a))return true;if(f!=a.id)if($(a).hasClass("Wt-suggest-onedit")){f=a.id;v=false}else if($(a).hasClass("Wt-suggest-dropdown")&&b.keyCode==40){f=a.id;v=true}else{f=null;return true}var h=o?d.getElement(o):null;if(e()&&h)if(b.keyCode==13||b.keyCode==9){p(h);d.cancelEvent(b);setTimeout(function(){a.focus()},0);return false}else if(b.keyCode==40||b.keyCode==38||
b.keyCode==34||b.keyCode==33){if(b.type.toUpperCase()=="KEYDOWN"){K=true;d.cancelEvent(b,d.CancelDefaultAction)}if(b.type.toUpperCase()=="KEYPRESS"&&K==true){d.cancelEvent(b);return false}var k=h,F=b.keyCode==40||b.keyCode==34;b=b.keyCode==34||b.keyCode==33?g.clientHeight/h.offsetHeight:1;var n;for(n=0;k&&n<b;++n){var w=B(k,F);if(!w)break;k=w}if(k&&d.hasTag(k,"LI")){h.className="";k.className="active";o=k.id}return false}return b.keyCode!=13&&b.keyCode!=9};this.filtered=function(a,b){C=a;N=b;r.refilter(E)};
this.refilter=function(a){if(f){var b=o?d.getElement(o):null,h=d.getElement(f),k=G(h),F=g.childNodes,n=u&&a!=null?a:k(null);E=u?a:h.value;if(q>0||t)if(n.length<q&&!v){m();return}else{a=N?n:n.substring(0,Math.max(C!==null?C.length:0,q));if(a!=C)if(a!=M){M=a;s.emit(g,"filter",a)}}var w=a=null;n=v&&n.length==0;var x,O;x=0;for(O=F.length;x<O;++x){var j=F[x];if(d.hasTag(j,"LI")){var H=j.firstChild;if(j.orig==null)j.orig=H.firstChild.innerHTML;var I=k(j.orig),P=n||I.match;if(I.suggestion!=H.firstChild.innerHTML)H.firstChild.innerHTML=
I.suggestion;if(P){if(j.style.display!="")j.style.display="";if(a==null)a=j;if(x==this.defaultValue)w=j}else if(j.style.display!="none")j.style.display="none";if(j.className!="")j.className=""}}if(a==null)m();else{if(!e()){i(h);r.showPopup(h);b=null}if(!b||b.style.display=="none"){b=w||a;b.parentNode.scrollTop=0;o=b.id}b.className="active";J(b)}}};this.editKeyUp=function(a,b){if(f!=null)if(c(a))if(!(!e()&&(b.keyCode==13||b.keyCode==9)))if(b.keyCode==27||b.keyCode==37||b.keyCode==39)m();else if(a.value!=
E){f=a.id;r.refilter(a.value)}else(a=o?d.getElement(o):null)&&J(a)};g.onclick=l;g.onscroll=function(){if(D){clearTimeout(D);var a=d.getElement(f);a&&a.focus()}};this.delayHide=function(a){D=setTimeout(function(){D=null;if(g&&(a==null||f==a.id))m()},300)}});
WT_DECLARE_WT_MEMBER(2,JavaScriptConstructor,"WSuggestionPopupStdMatcher",function(s,g,y,G,q,t,z){function u(c){var e=c.value;c=c.selectionStart?c.selectionStart:e.length;for(var i=y?e.lastIndexOf(y,c-1)+1:0;i<c&&G.indexOf(e.charAt(i))!=-1;)++i;return{start:i,end:c}}this.match=function(c){var e=u(c),i=c.value.substring(e.start,e.end),l;l=t.length==0?q.length!=0?"(^|(?:["+q+"]))":"(^)":"("+t+")";l+="("+i.replace(new RegExp("([\\^\\\\\\][\\-.$*+?()|{}])","g"),"\\$1")+")";l=new RegExp(l,"gi");return function(p){if(!p)return i;
var m=false;if(i.length){var B=p.replace(l,"$1"+s+"$2"+g);if(B!=p){m=true;p=B}}return{match:m,suggestion:p}}};this.replace=function(c,e,i){e=u(c);var l=c.value.substring(0,e.start)+i+z;if(e.end<c.value.length)l+=c.value.substring(e.end,c.value.length);c.value=l;if(c.selectionStart){c.selectionStart=e.start+i.length+z.length;c.selectionEnd=c.selectionStart}}});
